﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace Studio
{
	// Token: 0x020004CA RID: 1226
	public class ItemGroupList : MonoBehaviour
	{
		// Token: 0x1700038A RID: 906
		// (get) Token: 0x06001F3A RID: 7994 RVA: 0x000C2AFC File Offset: 0x000C0CFC
		// (set) Token: 0x06001F3B RID: 7995 RVA: 0x000C2B04 File Offset: 0x000C0D04
		private int count { get; set; }

		// Token: 0x06001F3C RID: 7996 RVA: 0x000C2B10 File Offset: 0x000C0D10
		private void OnSelect(int _no)
		{
			if (MathfEx.RangeEqualOn<int>(0, this.select, this.count - 1))
			{
				this.listNode[this.select].select = false;
			}
			if (MathfEx.RangeEqualOn<int>(0, _no, this.count - 1))
			{
				this.listNode[_no].select = true;
			}
			if (this.select != _no)
			{
				this.itemList.InitList(this.listNode[_no].key);
			}
			this.select = _no;
		}

		// Token: 0x06001F3D RID: 7997 RVA: 0x000C2BA4 File Offset: 0x000C0DA4
		private void Start()
		{
			this.listNode = new List<ItemGroupList.NodeInfo>();
			foreach (KeyValuePair<int, string> keyValuePair in Singleton<Info>.Instance.dicItemGroup)
			{
				GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.objectPrefab);
				gameObject.transform.SetParent(this.transformRoot, false);
				ItemGroupList.NodeInfo nodeInfo = new ItemGroupList.NodeInfo(keyValuePair.Key, gameObject.GetComponent<StudioNode>());
				nodeInfo.active = true;
				int no = this.listNode.Count;
				nodeInfo.node.addOnClick = delegate()
				{
					this.OnSelect(no);
				};
				nodeInfo.text = keyValuePair.Value;
				this.listNode.Add(nodeInfo);
			}
			this.select = -1;
			this.count = this.listNode.Count;
		}

		// Token: 0x0400210F RID: 8463
		[SerializeField]
		private Transform transformRoot;

		// Token: 0x04002110 RID: 8464
		[SerializeField]
		private GameObject objectPrefab;

		// Token: 0x04002111 RID: 8465
		[SerializeField]
		private ItemList itemList;

		// Token: 0x04002112 RID: 8466
		private List<ItemGroupList.NodeInfo> listNode;

		// Token: 0x04002113 RID: 8467
		private int select = -1;

		// Token: 0x020004CB RID: 1227
		private class NodeInfo
		{
			// Token: 0x06001F3E RID: 7998 RVA: 0x000C2CAC File Offset: 0x000C0EAC
			public NodeInfo(int _key, StudioNode _node)
			{
				this.key = _key;
				this.node = _node;
			}

			// Token: 0x1700038B RID: 907
			// (get) Token: 0x06001F3F RID: 7999 RVA: 0x000C2CC4 File Offset: 0x000C0EC4
			// (set) Token: 0x06001F40 RID: 8000 RVA: 0x000C2CCC File Offset: 0x000C0ECC
			public int key { get; private set; }

			// Token: 0x1700038C RID: 908
			// (get) Token: 0x06001F41 RID: 8001 RVA: 0x000C2CD8 File Offset: 0x000C0ED8
			// (set) Token: 0x06001F42 RID: 8002 RVA: 0x000C2CE0 File Offset: 0x000C0EE0
			public StudioNode node { get; private set; }

			// Token: 0x1700038D RID: 909
			// (get) Token: 0x06001F43 RID: 8003 RVA: 0x000C2CEC File Offset: 0x000C0EEC
			// (set) Token: 0x06001F44 RID: 8004 RVA: 0x000C2CFC File Offset: 0x000C0EFC
			public bool select
			{
				get
				{
					return this.node.select;
				}
				set
				{
					this.node.select = value;
				}
			}

			// Token: 0x1700038E RID: 910
			// (get) Token: 0x06001F45 RID: 8005 RVA: 0x000C2D0C File Offset: 0x000C0F0C
			// (set) Token: 0x06001F46 RID: 8006 RVA: 0x000C2D1C File Offset: 0x000C0F1C
			public bool active
			{
				get
				{
					return this.node.active;
				}
				set
				{
					this.node.active = value;
				}
			}

			// Token: 0x1700038F RID: 911
			// (get) Token: 0x06001F47 RID: 8007 RVA: 0x000C2D2C File Offset: 0x000C0F2C
			// (set) Token: 0x06001F48 RID: 8008 RVA: 0x000C2D3C File Offset: 0x000C0F3C
			public string text
			{
				get
				{
					return this.node.text;
				}
				set
				{
					this.node.text = value;
				}
			}
		}
	}
}
